51865e58064216b6e440819d159410df693cfd30,fabric/fabric-configadmin/src/main/java/org/fusesource/fabric/configadmin/ZooKeeperConfigAdminBridge.java,ZooKeeperConfigAdminBridge,load,#String#,164
Before Change
try {
Hashtable props = new Hashtable();
load(pid, node, props);
InterpolationHelper.performSubstitution(props, new InterpolationHelper.SubstitutionCallback() {
public String getValue(String key) {
if (key.startsWith("zk:")) {
try {
return new String(ZkPath.loadURL(zooKeeper, key), "UTF-8");
} catch (KeeperException.ConnectionLossException e) {
throw new RuntimeException(e);
} catch (Exception e) {
LOGGER.warn("Could not load zk value: {}. This exception will be ignored.", key, e);
}
} else {
String value = key;
BundleContext context = getBundleContext();
if (context != null) {
value = context.getProperty(key);
}
if (value == null) {
value = System.getProperty(key, "");
}
return value;
}
return key;
}
});
return props;
} catch (InterruptedException e) {
throw (IOException) new InterruptedIOException("Error loading pid " + pid).initCause(e);
} catch (KeeperException e) {
After Change
}
public Map<String, Hashtable> load(Set<String> pids) throws IOException {
final Map<String, Hashtable> configs = new HashMap<String, Hashtable>();
for (String pid : pids) {
try {
Hashtable props = new Hashtable();
load(pid, node, props);
configs.put(pid, props);
} catch (InterruptedException e) {
throw (IOException) new InterruptedIOException("Error loading pid " + pid).initCause(e);
} catch (KeeperException e) {
throw (IOException) new IOException("Error loading pid " + pid).initCause(e);
}
}
for (Map.Entry<String, Hashtable> entry : configs.entrySet()) {
Hashtable props = entry.getValue();
InterpolationHelper.performSubstitution(props, new InterpolationHelper.SubstitutionCallback() {
public String getValue(String key) {
if (key.startsWith("zk:")) {
try {
return new String(ZkPath.loadURL(zooKeeper, key), "UTF-8");
} catch (KeeperException.ConnectionLossException e) {
throw new RuntimeException(e);
} catch (Exception e) {
LOGGER.warn("Could not load zk value: {}. This exception will be ignored.", key, e);
}
} else if (key.matches(PROFILE_PROP_REGEX)) {
String pid = key.substring("profile:".length(), key.indexOf("/"));
String propertyKey = key.substring(key.indexOf("/") + 1);
Hashtable targetProps = configs.get(pid);
if (targetProps != null && targetProps.containsKey(propertyKey)) {
return (String) targetProps.get(propertyKey);
} else {
return key;
}
} else {
String value = key;
BundleContext context = getBundleContext();
if (context != null) {
value = context.getProperty(key);
}
if (value == null) {
value = System.getProperty(key, "");
}
return value;
}
return key;
}
});
}
return configs;
}
private static BundleContext getBundleContext() {